﻿
$(function () {
    $("#btnAddressPostContent").click(function () {
        $("#AddressBookPost").show();
        $("#AddressBookPost :input[type!='submit']").val("");
        $("#AddressBookPost :hidden").val("0");
        document.documentElement.scrollTop = document.body.clientHeight - 700;
    });

    $(":input[name='btnModify'],:input[name='addressId']").click(function () {
        _tr = $(this).parents("tr").find("td");
        var reallyName = _tr.eq(1).text();
        var mobile = _tr.eq(2).text();
        var phone = _tr.eq(3).text();
        var address = _tr.eq(4).text();
        var description = _tr.eq(6).text();
        var addressId = _tr.find(":hidden[name='addressId']").val();
        var postNo = _tr.eq(5).text();
        $("#AddressBookPost").show();
        $("#AddressBookPost :input[name='ReallyName']").val($.trim(reallyName));
        $("#AddressBookPost :input[name='Mobile']").val($.trim(mobile));
        $("#AddressBookPost :input[name='Phone']").val($.trim(phone));
        $("#AddressBookPost :input[name='Address']").val($.trim(address));
        $("#AddressBookPost :input[name='Description']").val($.trim(description));
        $("#AddressBookPost :input[name='AddressId']").val($.trim(addressId)); 
        $("#AddressBookPost :input[name='PostNo']").val($.trim(postNo));
        //document.documentElement.scrollTop = document.body.clientHeight - 700;
        $("#AddressBookPost :submit").focus();
    });

    $(":input[name='btnDelete']").click(function () {
        if (confirm("确定要删除吗？删除收货人地址可能导致你的货物无法正确投递，请谨慎操作。")) {
            var addressId = $(this).parents("tr").find(":hidden[name='addressId']").val();
            $.post(window.cr_deleteAddressItem_Url, { addressId: addressId }, function () { location.replace(document.URL) });
        }
    });
});
